package WebGamble;

import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.json.simple.*;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import java.awt.BorderLayout;
import javax.swing.JPanel;

public class YY365Auto extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	static String baseUrl = "http://www.yy365.com/";
	static Random rand = new Random();
	static String[] poemSet = { "海内存知己, 天涯若比邻", "劝君更进一杯酒，西出阳关无故人",
			"孤帆远影碧空尽，惟见长江天际流", "桃花潭水深千尺，不及汪伦送我情", "莫愁前路无知己，天下谁人不识君",
			"思君若汶水,浩荡寄南征", "结交在相知,骨肉何必亲", "丈夫志四海,万里犹比邻", "相知无远近,万里尚为邻",
			"少年乐新知,衰暮思故友", "以文常会友,唯德自成邻", "人生结交在终结,莫为升沉中路分", "人生交契无老少,论交何必先同调",
			"友如作画须求淡,山似论文不喜平", "折花逢驿使，寄与陇头人", "江南无所有，聊赠一枝春", "同门为朋，同志为友",
			"友谊是一种温静与沉着的爱，为理智所引导，习惯所结成，从长久的认识与共同的契合而产生，没有嫉妒，也没有恐惧",
			"友谊永远是一个甜柔的责任，从来不是一种机会", "真正的友情，是一株成长缓慢的植物", "亲善产生幸福，文明带来和谐",
			"挚友如异体同心", "世间最美好的东西，莫过于有几个头脑和心地都很正直的严正的朋友",
			"和你一同笑过的人，你可能把他忘掉；但是和你一同哭过的人，你却永远不忘", "在各种孤独中间，人最怕精神上的孤独",
			"友情为人生之酒", "到月亮上去不算太远；我们要走的最大距离还是在我们之间", "友谊是培养人的感情的学校",
			"如果说，友谊能够调剂人的感情的话，那么友谊的又一种作用则是能增进人的智慧",
			"友谊像清晨的雾一样纯洁，奉承并不能得到友谊，友谊只能用忠实去巩固它", "友谊是美德之手段，并且本身就是美德，是共同的美德",
			"朋友之间感情真诚，敌人就会无隙可乘", "友谊永远是一个甜柔的责任，从来不是一种机会",
			"友谊、活跃和青春的歌声会减轻我们的痛苦", "撇开友谊，无法谈青春，因为友谊是点缀青春的最美的花朵",
			"妥协对任何友谊都不是坚固的基础", "匹夫不可以不慎取友。友者，所以相有也", "二人同心，其利断金；同心之言，其香如兰",
			"习与正人居之，不能无正也；犹生长于齐，不能不齐语也", "君子拙于不知己，而信于知己", "不知其人，视其友",
			"掘井须到流，结交须到头", "山河不足重，重在遇知己", "择友如淘金，沙尽不得宝", "人生交结在终始，莫以开沉中路分",
			"亲之割之不断，疏者属之不坚", "势力之交，古人羞之", "交友投分，切磨箴视", "相见情已深，未语可知心",
			"当君远相知，不道云海深", "子猷没后知音少，粉节霜筠漫岁寒", "何者谓知音，知音难漫寻", "既无师旷耳，安有伯牙琴",
			"正是江南好风景，落花时节又逢君", "恶人相远离，善者近相知", "不就利，不违害，不强交，不苟绝，惟有道者能之",
			"贫游不可忘，久交念敦敬" };
	static String[] commentSet = { "不错", "打卡", "好", "来互访", "求互访", "今天天气不错",
			"今天是个好天气", "来来来", "我来了", "访友来啦", "来看看，记得回访", "朋友你好", "来回复", "来一发",
			"有空就来看看", "互访攒人气", "来踩一踩", "人气满了没", "求投资", "求人气", "赚积分", "访问好友",
			"天天来访问", "加油", "留贴", "休息一下", "朋友,你好", "我来和你互动", "朋友们给点力", "今天心情不错",
			"大声喊出来", "我来访友了", "来踩踩", "有空就来看看", "看一眼", "挺不错", "灰常好", "有趣",
			"踩踩看", "猜猜我是谁", "来了", "访访看", "访友、打卡、赚积分", "吃了没", "吃饭了么", "相识为缘" };
	static String[] commentFollowingSet = { "啊", "哦", "嗯", "诶", "啦", "吧", "嘿",
			"嘿", "啊", "哦", "嗯", "诶", "啦", "吧" };
	static String[] commentFollowing0Set = { "！", "。", "》", "~", ":)", "^-^" };
	static String[] alphabet = { "a", "b", "c", "d", "e", "f", "g", "h", "i",
			"j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v",
			"w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I",
			"J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
			"W", "X", "Y", "Z" };
	static String[] emSet = { "[em1]", "[em2]", "[em3]", "[em4]", "[em6]",
			"[em7]", "[em8]", "[em9]", "[em10]", "[em11]" };

	static private HttpResponse httpResponse;
	static private DefaultHttpClient httpClient = new DefaultHttpClient();

	static public class showImg extends JPanel {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		JLabel jl = null;
		ImageIcon img = null;

		public showImg(InputStream bmpFile) throws IOException {
			img = new ImageIcon(ImageIO.read(bmpFile));
			jl = new JLabel(img);
			this.setLayout(new BorderLayout());
			this.add(jl, BorderLayout.CENTER);
		}
	}

	@SuppressWarnings("deprecation")
	public static void main(String[] args) throws ClientProtocolException,
			IOException, InterruptedException, ParseException {
		JSONParser jp = new JSONParser();
		JSONObject jobj = new JSONObject();

		HttpGet httpGet;
		httpGet = new HttpGet("http://www.yy365.com/login!retrieveImg.do");
		httpResponse = httpClient.execute(httpGet);
		String imgUrl = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
		httpGet.releaseConnection();
		jobj = (JSONObject) jp.parse(imgUrl);
		imgUrl = jobj.get("imgSrc").toString();

		httpGet = new HttpGet(baseUrl + imgUrl);
		httpResponse = httpClient.execute(httpGet);
		JFrame pane = null;
		if (args.length > 0 && Integer.parseInt(args[0]) >= 0) {
			// save the verify code
			File file = new File("VerifyCode_yy" + args[0] + ".gif");
			FileOutputStream outputStream = new FileOutputStream(file);
			InputStream inputStream = httpResponse.getEntity().getContent();
			byte b[] = new byte[1024];
			int j;
			while ((j = inputStream.read(b)) != -1) {
				outputStream.write(b, 0, j);
			}
			outputStream.flush();
			outputStream.close();
		} else {
			// show the verify code directly
			pane = new JFrame("Image Pane");
			pane.getContentPane().add(
					new showImg(httpResponse.getEntity().getContent()));
			pane.pack();
			pane.setVisible(true);
		}
		httpGet.releaseConnection();
		System.out.println("Please enter the verify code:");
		String VerifyCode;
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		VerifyCode = reader.readLine();

		HttpPost httpPost = new HttpPost(baseUrl + "login.do");
		String[] loginList = { "gonerfile@126.com", "ztqyyy@126.com",
				"yxnyyy@126.com", "wdfyyy@yeah.net", "lx1yyy@126.com", "wcy1yyy@126.com", 
				"cyx0yyy@126.com", "cz0yyy@126.com", "yfhyyy@126.com", "xgcyyy@126.com", 
				"wyxxx0@126.com", "swj012@126.com", "ltn111@126.com", "ljj210@126.com", 
				"jyfttt@126.com", "hyr013@126.com", "gyy654@126.com", "fyz012@sina.com", 
				"dx7898@sina.com", "cz2210@126.com" };
		int loginSelect = 11;
		if (args.length > 0)
			loginSelect = Integer.parseInt(args[0]);
		List<NameValuePair> params = new ArrayList<NameValuePair>();
		params.add(new BasicNameValuePair("rememberMe", "true"));
		params.add(new BasicNameValuePair("ytsnsEmail", loginList[loginSelect]));
		params.add(new BasicNameValuePair("password", "123321"));
		params.add(new BasicNameValuePair("loginvalidateCode", VerifyCode));
		params.add(new BasicNameValuePair("k", "login_key"));

		httpPost.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
		httpResponse = httpClient.execute(httpPost);
		if (httpResponse.getStatusLine().getStatusCode() == 302) {
			System.out.println("Login success...");
		}
		String loginHtml = EntityUtils.toString(httpResponse.getEntity(),
				"UTF-8");
		httpPost.releaseConnection();

		if (args.length == 0)
			pane.dispose();

		int runningCount = 0;

		JSONArray jarr;
		while (true) {
			httpGet = new HttpGet(
					"http://www.yy365.com/feed!getmyFeed.do?sign=allfriend");
			httpResponse = httpClient.execute(httpGet);
			String html = EntityUtils.toString(httpResponse.getEntity(),
					"utf-8");
			httpGet.releaseConnection();
			jobj = (JSONObject) jp.parse(html);
			jarr = (JSONArray) jobj.get("list");
			if (rand.nextBoolean() == true) {
				jobj = (JSONObject) jarr.get(rand.nextInt(10));
			} else if (rand.nextBoolean() == true) {
				jobj = (JSONObject) jarr.get(rand.nextInt(24));
			} else {
				jobj = (JSONObject) jarr.get(rand.nextInt(45));
			}
			String uid = jobj.get("uid").toString();
			if (!jobj.containsKey("artid"))
				continue;
			String artid = jobj.get("artid").toString();
			System.out.println(jobj.get("uname").toString() + ": "
					+ jobj.get("sim").toString());

			SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");

			long startT = System.currentTimeMillis(), endT;

			httpPost = new HttpPost(baseUrl + "miniblog!saveComment.do?mainId="
					+ artid + "&userId=" + uid);
			List<NameValuePair> gambleParams = new ArrayList<NameValuePair>();

			String content = "";
			int r = rand.nextInt(commentSet.length + 15);
			if (r < commentSet.length) {
				if (rand.nextInt(3) == 0) {
					content = poemSet[rand.nextInt(poemSet.length)];
				} else {
					content = content + commentSet[r];
					for (int i = 0; i < rand.nextInt(2) + 1; i++) {
						content = content
								+ commentFollowingSet[rand
										.nextInt(commentFollowingSet.length)];
					}
					r = rand.nextInt(commentFollowing0Set.length);
					for (int i = 0; i < rand.nextInt(6) + 1; i++) {
						content = content + commentFollowing0Set[r];
					}
				}
			} else {
				for (int i = 0; i < rand.nextInt(40) + 6; i++) {
					content = content + alphabet[rand.nextInt(52)];
				}
			}
			System.out.println(content);

			gambleParams.add(new BasicNameValuePair("content", content));
			gambleParams.add(new BasicNameValuePair("toUserId", "0"));
			gambleParams.add(new BasicNameValuePair("commentId", "0"));
			gambleParams.add(new BasicNameValuePair("toUserName", ""));
			gambleParams.add(new BasicNameValuePair("toLevel", "0"));
			httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
					HTTP.UTF_8));
			httpPost.addHeader("Host", "www.yy365.com");
			httpPost.addHeader("Referer",
					"http://www.yy365.com/miniblog!showMiniBlog.do?id=" + artid
							+ "&userId=" + uid);
			httpPost.addHeader("User-Agent",
					"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
			httpResponse = httpClient.execute(httpPost);
			html = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
			httpPost.releaseConnection();
			System.out.println(html);
			
			//miniblog
			httpGet = new HttpGet("http://www.yy365.com/miniblog!listAll.do");
			httpResponse = httpClient.execute(httpGet);
			html = EntityUtils.toString(httpResponse.getEntity(),
					"utf-8");
			httpGet.releaseConnection();
			Document docu = Jsoup.parse(html);
			Elements elems;
			elems = docu.select(".mini_title");
			for(Element elem : elems) {
				String hreft = elem.select(".r a").get(0).attr("href");
				String artidt = hreft.substring(hreft.length() - 10, hreft.length() - 2);
				hreft = elem.select(".l a").get(0).attr("href");
				String uidt = hreft.substring(hreft.length() - 8, hreft.length());
				
				httpPost = new HttpPost(baseUrl + "miniblog!saveComment.do?mainId="
						+ artidt + "&userId=" + uidt);
				gambleParams = new ArrayList<NameValuePair>();

				content = "";
				r = rand.nextInt(commentSet.length + 15);
				if (r < commentSet.length) {
					if (rand.nextInt(3) == 0) {
						content = poemSet[rand.nextInt(poemSet.length)];
					} else {
						content = content + commentSet[r];
						for (int i = 0; i < rand.nextInt(2) + 1; i++) {
							content = content
									+ commentFollowingSet[rand
											.nextInt(commentFollowingSet.length)];
						}
						r = rand.nextInt(commentFollowing0Set.length);
						for (int i = 0; i < rand.nextInt(6) + 1; i++) {
							content = content + commentFollowing0Set[r];
						}
					}
				} else {
					for (int i = 0; i < rand.nextInt(40) + 6; i++) {
						content = content + alphabet[rand.nextInt(52)];
					}
				}
				System.out.println(content);

				gambleParams.add(new BasicNameValuePair("content", content));
				gambleParams.add(new BasicNameValuePair("toUserId", "0"));
				gambleParams.add(new BasicNameValuePair("commentId", "0"));
				gambleParams.add(new BasicNameValuePair("toUserName", ""));
				gambleParams.add(new BasicNameValuePair("toLevel", "0"));
				httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
						HTTP.UTF_8));
				httpPost.addHeader("Host", "www.yy365.com");
				httpPost.addHeader("Referer",
						"http://www.yy365.com/miniblog!showMiniBlog.do?id=" + artidt
								+ "&userId=" + uidt);
				httpPost.addHeader("User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
				httpResponse = httpClient.execute(httpPost);
				html = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
				httpPost.releaseConnection();
				System.out.println(html);
				Thread.sleep(rand.nextInt(8) * 500 + 500);
			}

			endT = System.currentTimeMillis();
			System.out.println();
			int hours = new Date().getHours();
			if (hours >= 23 || hours < 8) {
				System.out.println("Night mode...");
				Thread.sleep(rand.nextInt(800) * 5000 + 2400000
						+ rand.nextInt(120000));
			} else {
				System.out.println("Day mode...");
				Thread.sleep(rand.nextInt(100) * 1000 + 1200000
						+ rand.nextInt(5000));
			}

			if (rand.nextInt(8) == 3) {
				// dairy
				content = "";
				httpGet = new HttpGet(
						"http://sg.qsgct999.cn/a/shangganrizhi/shangganrizhidaquan/list_31_"
								+ (rand.nextInt(412) + 1) + ".html");
				httpResponse = httpClient.execute(httpGet);
				String htm = EntityUtils.toString(httpResponse.getEntity(),
						"gb2312");
				httpGet.releaseConnection();
				Document document = Jsoup.parse(htm);
				Elements elements;
				elements = document.select(".pleft .plist ul.e2 li a.title");
				if(elements.size() <= 0)
					continue;
				String artUrl = elements.get(rand.nextInt(elements.size()))
						.attr("href");

				httpGet = new HttpGet(artUrl);
				httpResponse = httpClient.execute(httpGet);
				htm = EntityUtils.toString(httpResponse.getEntity(), "gb2312");
				httpGet.releaseConnection();
				document = Jsoup.parse(htm);
				elements = document
						.select(".pleft .viewbox > .title:eq(0) font");
				String title = elements.text();
				System.out.println("title: " + title);
				elements = document.select(".pleft .viewbox > .intro");
				content = content + "引言：" + elements.text() + "……\n";
				elements = document.select(".pleft .viewbox #abody p");
				if (elements.size() == 0) {
					elements = document.select(".pleft .viewbox #abody");
					content = content
							+ elements.text().replaceAll("<br>", "\n") + "\n";
				} else {
					for (Element elem : elements) {
						content = content
								+ elem.text().replaceAll("<br>", "\n") + "\n";
					}
				}
				// System.out.println("content: " + content);

				httpGet = new HttpGet("http://www.yy365.com/blog!addBlog.do");
				httpResponse = httpClient.execute(httpGet);
				htm = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
				httpGet.releaseConnection();
				document = Jsoup.parse(htm);
				elements = document.select("#categoryid option:eq(0)");
				String categoryid = elements.attr("value");

				httpPost = new HttpPost("http://www.yy365.com/blog!saveBlog.do");
				gambleParams = new ArrayList<NameValuePair>();
				gambleParams.add(new BasicNameValuePair("blogTitle", title));
				gambleParams
						.add(new BasicNameValuePair("blogContent", content));
				gambleParams.add(new BasicNameValuePair("_isAjaxRequest",
						"true"));
				gambleParams.add(new BasicNameValuePair("categoryIds", ""));
				gambleParams.add(new BasicNameValuePair("categoryIds1", ""));
				gambleParams.add(new BasicNameValuePair("categoryid",
						categoryid));
				gambleParams.add(new BasicNameValuePair("label1", ""));
				gambleParams.add(new BasicNameValuePair("label2", ""));
				gambleParams.add(new BasicNameValuePair("label3", ""));
				gambleParams.add(new BasicNameValuePair("openType", "0"));
				gambleParams
						.add(new BasicNameValuePair("ownerBlog", "checkbox"));
				gambleParams.add(new BasicNameValuePair("share", "0"));
				httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
						HTTP.UTF_8));
				httpPost.addHeader("Host", "www.yy365.com");
				httpPost.addHeader("Referer",
						"http://www.yy365.com/blog!addBlog.do");
				httpPost.addHeader("User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
				httpResponse = httpClient.execute(httpPost);
				html = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
				httpPost.releaseConnection();
				System.out.println();
			}

			if (rand.nextInt(8) == 4) {
				// weibo
				httpGet = new HttpGet("http://news.baidu.com/");
				httpResponse = httpClient.execute(httpGet);
				String htm = EntityUtils.toString(httpResponse.getEntity(),
						"gb2312");
				httpGet.releaseConnection();
				Document document = Jsoup.parse(htm);
				Elements elements;
				if (rand.nextInt(4) == 0) {
					elements = document
							.select(".l-left-col .hotnews strong font");
				} else {
					elements = document.select(".l-left-col a");
				}
				if (elements.size() <= 0) {
					content = "现在是" + (new Date().toLocaleString())
							+ "咯，大家都在干啥捏~~~？";
				} else {
					int idx = rand.nextInt(elements.size());
					content = elements.get(idx).text();
				}
				System.out.println(content);

				httpPost = new HttpPost(
						"http://www.yy365.com/miniblog!saveMiniBlog.do?t="
								+ new Date().toString().replaceAll(" ", "%20"));
				gambleParams = new ArrayList<NameValuePair>();

				gambleParams.add(new BasicNameValuePair("content", content));
				gambleParams.add(new BasicNameValuePair("_isAjaxRequest",
						"true"));
				gambleParams.add(new BasicNameValuePair("categories", ""));
				gambleParams.add(new BasicNameValuePair("openType", "3"));
				gambleParams.add(new BasicNameValuePair("push", "0"));
				httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
						HTTP.UTF_8));
				httpPost.addHeader("Host", "www.yy365.com");
				httpPost.addHeader("Referer",
						"http://www.yy365.com/miniblog!listMy.do");
				httpPost.addHeader("User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
				httpResponse = httpClient.execute(httpPost);
				html = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
				httpPost.releaseConnection();

				endT = System.currentTimeMillis();
				System.out.println();
			}

			httpGet = new HttpGet("http://www.yy365.com/info!commentInfo.do");
			httpResponse = httpClient.execute(httpGet);
			String htm = EntityUtils
					.toString(httpResponse.getEntity(), "UTF-8");
			httpGet.releaseConnection();
			Document document = Jsoup.parse(htm);
			Elements elements;
			elements = document.select(".ph_com .hylist_nr .top.underline a");
			if (elements.size() > 0) {
				for (Element elem : elements) {
					String _artid;
					String _uid;
					String superid;
					String type;
					String href = elem.attr("href");
					href = href.substring(21);
					Pattern p = Pattern.compile("'[0-9]+'");
					Matcher m = p.matcher(href);
					m.find();
					_uid = m.group();
					_uid = _uid.substring(1, _uid.length() - 1);
					m.find();
					_artid = m.group();
					_artid = _artid.substring(1, _artid.length() - 1);
					m.find();
					superid = m.group();
					superid = superid.substring(1, superid.length() - 1);
					m.find();
					type = m.group();
					type = type.substring(1, type.length() - 1);
					int t = Integer.parseInt(type);
					String commentUrl = "";
					if (t == 0) {
						commentUrl = "home!getPersonalData.do?id=" + _artid
								+ "&flag=5";
					} else if (t == 1) {
						commentUrl = "blog!viewBlog.do?blogId=" + _artid
								+ "&userId=" + _uid;
					} else if (t == 2) {
						// 回复迷你博客。。。
						if(rand.nextInt(7) <= 4)
							continue;
						if(rand.nextInt(30) == 1)
							break;
						commentUrl = "miniblog!showMiniBlog.do?id=" + _artid
								+ "&userId=" + _uid;
						httpGet = new HttpGet(
								"http://www.yy365.com/miniblog!getComment.do?id="
										+ _artid + "&userId=" + _uid
										+ "&pageIndex=0&pageSize=50");
						httpResponse = httpClient.execute(httpGet);
						String ht = EntityUtils.toString(
								httpResponse.getEntity(), "UTF-8");
						httpGet.releaseConnection();
						jobj = (JSONObject) jp.parse(ht);
						jobj = (JSONObject) jobj.get("page");
						jarr = (JSONArray) jobj.get("elements");
						for (int j = 0; j < jarr.size(); j++) {
							if (rand.nextInt(60) != 0)
								continue;
							jobj = (JSONObject) jarr.get(j);
							String commentid = jobj.get("id").toString();
							String tolevel = jobj.get("level").toString();
							String userid = jobj.get("guestId").toString();
							if (userid.compareTo(_uid) == 0) {
								System.out.println("same userid...");
								continue;
							}
							jobj = (JSONObject) jobj.get("user");
							String username = jobj.get("name").toString();
							String replyContent = "";
							if (rand.nextBoolean() == true) {
								replyContent = "来回复看看";
							} else {
								if (rand.nextBoolean()) {
									replyContent = "来互动";
								} else {
									replyContent = commentSet[rand
											.nextInt(commentSet.length)];
								}
							}
							for (int i = 0; i < rand.nextInt(2) + 1; i++) {
								replyContent = replyContent
										+ commentFollowingSet[rand
												.nextInt(commentFollowingSet.length)];
							}
							r = rand.nextInt(commentFollowing0Set.length);
							for (int i = 0; i < rand.nextInt(2) + 1; i++) {
								replyContent = replyContent
										+ commentFollowing0Set[r];
							}
							for (int i = 0; i < rand.nextInt(5) + 1; i++) {
								replyContent = replyContent
										+ emSet[rand.nextInt(emSet.length)];
							}
							System.out.println(replyContent);

							httpPost = new HttpPost(
									"http://www.yy365.com/miniblog!saveComment.do?mainId="
											+ _artid
											+ "&userId="
											+ _uid
											+ "&"
											+ new Date().toString().replaceAll(
													" ", "%20"));
							gambleParams = new ArrayList<NameValuePair>();

							gambleParams.add(new BasicNameValuePair(
									"commentId", commentid));
							gambleParams.add(new BasicNameValuePair("content",
									replyContent));
							gambleParams.add(new BasicNameValuePair("toLevel",
									tolevel));
							gambleParams.add(new BasicNameValuePair(
									"toUserName", username));
							gambleParams.add(new BasicNameValuePair("toUserId",
									userid));
							gambleParams.add(new BasicNameValuePair(
									"_isAjaxRequest", "true"));
							httpPost.setEntity(new UrlEncodedFormEntity(
									gambleParams, HTTP.UTF_8));
							httpPost.addHeader("Host", "www.yy365.com");
							httpPost.addHeader("Referer", baseUrl + commentUrl);
							httpPost.addHeader("User-Agent",
									"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
							httpResponse = httpClient.execute(httpPost);
							ht = EntityUtils.toString(httpResponse.getEntity(),
									"UTF-8");
							System.out.println(ht);
							httpPost.releaseConnection();
							Thread.sleep(rand.nextInt(40) * 100 + 1000
									+ rand.nextInt(1000));
						}
					} else if (t == 3) {
						commentUrl = "photo!view.do?id=" + _artid + "&userId="
								+ _uid + "&albumId=" + superid;
					} else if (t == 4) {
						commentUrl = "activity!show.do?id=" + _artid;
					} else if (t == 5) {
						commentUrl = "topic!view.do?id=" + _artid + "&groupId="
								+ superid;
					}
					t = t + 5;
					type = String.valueOf(t);

					httpPost = new HttpPost(baseUrl + "info!removeComment.do");
					gambleParams = new ArrayList<NameValuePair>();

					gambleParams.add(new BasicNameValuePair("id", _artid));
					gambleParams.add(new BasicNameValuePair("type", type));
					gambleParams.add(new BasicNameValuePair("sign", "comment"));
					gambleParams.add(new BasicNameValuePair("_isAjaxRequest",
							"true"));
					httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
							HTTP.UTF_8));
					httpPost.addHeader("Host", "www.yy365.com");
					httpPost.addHeader("Referer",
							"http://www.yy365.com/info!commentInfo.do");
					httpPost.addHeader("User-Agent",
							"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
					httpResponse = httpClient.execute(httpPost);
					html = EntityUtils.toString(httpResponse.getEntity(),
							"UTF-8");
					httpPost.releaseConnection();
				}
				System.out.println("已删除。。。");
			}

			if (runningCount == 4) {
				runningCount = 0;
				httpPost = new HttpPost(
						"http://www.yy365.com/login!loginintegral.do");
				gambleParams = new ArrayList<NameValuePair>();
				gambleParams.add(new BasicNameValuePair("_isAjaxRequest",
						"true"));
				httpPost.setEntity(new UrlEncodedFormEntity(gambleParams,
						HTTP.UTF_8));
				httpPost.addHeader("Host", "www.yy365.com");
				httpPost.addHeader("Referer", "http://www.yy365.com/home.do");
				httpPost.addHeader("User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; rv:18.0) Gecko/20100101 Firefox/18.0");
				httpResponse = httpClient.execute(httpPost);
				html = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
				httpPost.releaseConnection();
				System.out.println("已打卡。。。");
			}
			runningCount++;
		}

	}
}